package com.bookstore.mappers;

import com.bookstore.pojo.Book;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface BookMapper {

    /**
     * 根据主键删除书本
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * 添加书本
     * @param record
     * @return
     */
    int insert(Book record);

    /**
     * 根据主键查询书本
     * @param id
     * @return
     */
    @MapKey("id")
    Book selectByPrimaryKey(Integer id);

    /**
     * 查询所有书本
     * @return
     */
    List<Book> selectAll(@Param("id")Integer id,@Param("name")String name,@Param("author")String author,
                         @Param("price")Double price,@Param("sales")Integer sales,@Param("stock")Integer stock);

    /**
     * 跟新书本信息
     * @param record
     * @return
     */
    int updateByPrimaryKey(Book record);

    public int getTotalCount();

    public List<Book> getAll();

    public List<Book> getPageList();

    int updateBook(@Param("book") Book book);
}